<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>单场景用例日志</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" href="../resources/favicon.ico" th:href="@{/static/favicon.ico}"/>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<div style="display: flex;justify-content: space-between;margin-top: 20px;margin-right: 20px;margin-left: 20px">
    <form class="layui-form" action="">
        <div class="form-group">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">接口地址:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" id="name" autocomplete="off" placeholder="请输入接口地址" class="layui-input" >
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">接口名称:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="tag" id="tag" autocomplete="off" placeholder="请输入接口名称" class="layui-input" >
                    </div>
                </div>

            </div>
        </div>

    </form>
    <div class="layui-inline">
        <button style="text-align: right" id="search_btn" class="layui-btn layui-btn-normal"><i class="layui-icon"></i>
            搜 索
        </button>
    </div>
</div>

<div style="margin-right: 20px;margin-left: 20px;margin-top: 20px">
    <table class="layui-show" id="dataTable" lay-filter="dataTable" style="width: 80%"></table>

</div>

<script type="text/html" id="success">
    {{#if (d.success == '0') { }}
    <span>失败</span>
    {{# }else if(d.success == '1'){ }}
    <span>成功</span>
    {{# } }}
</script>

<script src="/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    layui.use(['element', 'table', 'layer'], function () {
        var $ = layui.jquery,
            element = layui.element,
            layer = layui.layer,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: "#dataTable",
            url: '/va/singleReportList'+'?name='+ $("#name").val()+"&tag="+$("#tag").val()+"&uid="+JSON.parse(localStorage.getItem("user")).uid,
            cols: [
                [
                    {field: 'id', title: 'ID', width: 100, sort: true}
                    , {field: 'taskId', title: '任务ID', width: 200}
                    , {field: 'name', title: '接口地址', width: 200}
                    , {field: 'tag', title: '接口名称', width: 150}
                    , {field: 'success', title: '是否成功', width: 100, templet: "#success"}
                    , {field: 'result', title: '错误日志', width: 300}
                    , {field: 'req', title: '请求参数', width: 200}
                    , {field: 'res', title: '返回结果', width: 200}
                    , {field: 'runner', title: '执行用户', width: 150}
                    , {field: 'test_account_name', title: '执行账号', width: 150}
                    , {field: 'create_time', title: '执行时间', width: 200, sort: true,templet : "<div>{{layui.util.toDateString(d.create_time, 'yyyy年MM月dd日 HH:mm:ss')}}</div>"}
                ]
            ]
            , page: true
            // ,skin:"line"
            , id: 'dataReload'
        });

        //模块下拉
        $.ajax({
            url: "/va/kindList/0",
            async: false,
            type: "get",
            success: function (data) {
                console.log(data);
                var kindlist = data.data;
                for (var i = 0; i < kindlist.length; i++) {
                    $("#kind").append("<option value='" + kindlist[i].kindId + "'>" + kindlist[i].kindName + "</option>")
                }
                $("#kind").val(0);
                form.render();//菜单渲染 把内容加载进去
            },
            error: function () {
                console.log("出错！");
            }
        });

        //分类下拉
        form.on('select(selectkind)', function (data) {
            $("#kind2").empty();
            $.ajax({
                url: '/va/dirList/' + $("#kind").val(),
                async: false,
                type: "get",
                success: function (data) {
                    var dirList = data.data;
                    for (var i = 0; i < dirList.length; i++) {
                        $("#kind2").append("<option value='" + dirList[i].kindDirId + "'>" + dirList[i].dirName + "</option>")
                    }
                    $("#kind2").val(0);
                    form.render();//菜单渲染 把内容加载进去
                }
            });
        });

        //点击搜索后，重新加载表格数据
        $('#search_btn').on("click", function () {
            table.reload("dataReload", {
                method:"get",
                url: '/va/singleReportList'+'?name='+ $("#name").val()+"&tag="+$("#tag").val()+"&uid="+JSON.parse(localStorage.getItem("user")).uid,
                page:1
            })
        })

    });

</script>

</body>
</html>

